package com.jiazhong.example.project.bookstore.front.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiazhong.example.project.bookstore.commons.bean.Category;
import com.jiazhong.example.project.bookstore.commons.mapper.CategoryMapper;
import com.jiazhong.example.project.bookstore.commons.util.JsonResult;
import com.jiazhong.example.project.bookstore.commons.util.ResultTool;
import com.jiazhong.example.project.bookstore.front.service.CategoryService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {


    @Cacheable(cacheNames = "findByCategoryLimit", key = "#limit")
    public JsonResult findByCategoryLimit(int limit) {
        QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
        queryWrapper.last("limit " + limit);
        return ResultTool.success(list(queryWrapper));
    }
}
